import 'animate.css';
import Antd from 'ant-design-vue';

import { MotionPlugin } from '@vueuse/motion';
import { nanoid } from 'nanoid';
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import { createApp } from 'vue';
import App from './App.vue';
import './api/config/interceptor';
import directive from './directive';
import { triggerNotice } from './global/window/notify';
import './style/index.css';
import './style/index.scss';

const app = createApp(App);
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

/* 捕捉全局错误 */
app.config.errorHandler = (e: any) => {
  triggerNotice({
    content: `捕捉到一个异常，可能影响程序运行，错误信息如下：${e.toString()}`,
    title: '系统错误',
    type: 'temp',
    id: nanoid(),
    time: '',
    color: 'red',
    allowClose: true,
  });
};
// @ts-ignore
app.use(MotionPlugin);
app.use(Antd);
app.use(pinia);
app.use(directive);
app.mount('#app');
